import type { Dayjs } from 'dayjs';

import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace EdubaseHolidayAdjustmentSchoolApi {
  /** 学校假期调休信息 */
  export interface HolidayAdjustmentSchool {
    id: number; // 主键
    naturalYear: string; // 自然年度
    academicYear: string; // 学年
    schoolId: number; // 学校id
    infraAdjustmentId?: number; // 全局假期调休id
    infraHolidayId?: number; // 全局假期id
    adjustType?: number; // 调整类型
    holidayId: number; // 关联的假期ID
    originalDate?: Dayjs | string; // 原始日期
    adjustDate?: Dayjs | string; // 调整日期
    reason: string; // 调休原因
    status?: number; // 有效状态
    areaCode: number; // 所属行政区划
    isDefault?: boolean; // 是否默认
  }
}

/** 查询学校假期调休分页 */
export function getHolidayAdjustmentSchoolPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<
    PageResult<EdubaseHolidayAdjustmentSchoolApi.HolidayAdjustmentSchool>
  >('/edu/base/holiday-adjustment-school/page', data, { desensitize, encrypt });
}
/** 查询学校假期调休分页 默认*/
export function getHolidayAdjustmentSchoolPageDefault(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<
    PageResult<EdubaseHolidayAdjustmentSchoolApi.HolidayAdjustmentSchool>
  >('/edu/base/holiday-adjustment-school/page-default', data, {
    desensitize,
    encrypt,
  });
}
/** 查询学校假期调休详情 */
export function getHolidayAdjustmentSchool(id: number) {
  return requestClient.get<EdubaseHolidayAdjustmentSchoolApi.HolidayAdjustmentSchool>(
    `/edu/base/holiday-adjustment-school/get?id=${id}`,
  );
}

/** 新增学校假期调休 */
export function createHolidayAdjustmentSchool(
  data: EdubaseHolidayAdjustmentSchoolApi.HolidayAdjustmentSchool,
) {
  return requestClient.post('/edu/base/holiday-adjustment-school/create', data);
}

/** 修改学校假期调休 */
export function updateHolidayAdjustmentSchool(
  data: EdubaseHolidayAdjustmentSchoolApi.HolidayAdjustmentSchool,
) {
  return requestClient.put('/edu/base/holiday-adjustment-school/update', data);
}

/** 删除学校假期调休 */
export function deleteHolidayAdjustmentSchool(id: number) {
  return requestClient.delete(
    `/edu/base/holiday-adjustment-school/delete?id=${id}`,
  );
}

/** 批量删除学校假期调休 */
export function deleteHolidayAdjustmentSchoolList(ids: number[]) {
  return requestClient.delete(
    `/edu/base/holiday-adjustment-school/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出学校假期调休 */
export function exportHolidayAdjustmentSchool(params: any) {
  return requestClient.download(
    '/edu/base/holiday-adjustment-school/export-excel',
    { params },
  );
}
/** 更新学校默认假期调休状态 */
export function updateHolidayAdjustmentSchoolStatus(data: {
  id: number;
  status: number;
}) {
  return requestClient.put(
    '/edu/base/holiday-adjustment-school/update-default-status',
    data,
  );
}
